
const defaults = {
  title:'popupbox',
  avatar:'',
  name:'aa',
  content:'黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉黎莉莉',
}

import Vue from 'vue';
import PopupBoxC from './main.vue';

let instance;

const PopupBoxConstructor = Vue.extend(PopupBoxC);

const PopupBox = function (options,callback) {
  if(Vue.prototype.$isServer) return;
  options = options || {};
  let userOnClose = options.onClose;
  options.onClose = function () {
    PopupBox.close(userOnClose)
  };
  instance = new PopupBoxConstructor({
    data:options
  });
  instance.$mount();
  instance.visible = true;
  document.body.appendChild(instance.$el);
  return instance;
};


PopupBox.close = function (userOnClose) {
  instance.visible = false;

};


export default  PopupBox
